<ul id="widget-cats-menu" class="left-nav">
<?php foreach($cats as $cat) : ?>
    <li<?php if($cat->id==$this->selected_cat_id) echo ' class="selected"'; ?>><a href="<?php echo $cat->id; ?>"><span></span><?php echo $cat->name; ?></a></li>
<?php endforeach; ?>                                    
</ul>

<script type="text/javascript">
$('#widget-cats-menu li a').click(function(){
    var cat_id = $(this).attr('href');
    $('#widget-cats-menu li').removeClass('selected');
    $(this).parent().addClass('selected');    
    $.post(
        baseUrl + '/?r=Core/service/widget',
        {
            'WID' : 'Cms.widgets.WidgetsList',
            'selected_cat_id' : cat_id,
            'extra_data[page_id]' : $('#page_id').val(),
            'extra_data[revision_id]' : $('#revision_id').val(),
            'extra_data[container]' : $('#container').val(),
            'extra_data[route]' : $('#route').val(),
            'for_adding_into_page' : $('#for_adding_into_page').val()
        },
        function(data){
            $('#<?php echo $this->widgets_container_id; ?>').html(data);    
        }
    );
    return false;
});
</script>